import React from "react";
import ErrorPage from "@src/pages/error";
import {Navigate} from "react-router-dom";
import PrivateRoute from "@src/components/privateRoute"


const HomePage = React.lazy(() => import ("@src/pages/home"));
const LogInPage = React.lazy(() => import ("../pages/logIn"))
const News = React.lazy(() => import ("../pages/home/news"))
const NewsDefault = React.lazy(() => import("@src/pages/home/news/default"))
const PrivateChat = React.lazy(() => import("@src/pages/home/news/privateChat"))
const AddFriends = React.lazy(() => import("@src/pages/home/news/addFriends"))
const SearchUser = React.lazy(() => import("@src/pages/home/news/searchUser"))
const Contacts = React.lazy(() => import ("../pages/home/contacts"))
const Music = React.lazy(() => import ("../pages/home/music"))
const ChatRoom = React.lazy(() => import("@src/pages/home/chatRoom"))
const ChatRoomDetailed = React.lazy(() => import("@src/pages/home/chatRoom/chatRoomDetailed"))
const ChatRoomDefault = React.lazy(() => import("@src/pages/home/chatRoom/default"))
const SongsList = React.lazy(() => import("@src/pages/home/music/songsList"))
const MusicDefault = React.lazy(() => import("@src/pages/home/music/default"))
const SearchSuggest = React.lazy(() => import("../pages/home/music/searchSuggest"))
const Search = React.lazy(() => import("../pages/home/music/search"))
const CatList = React.lazy(() => import("@src/pages/home/music/catList"))
const SongDetail = React.lazy(() => import("@src/pages/home/music/songDetail"))
const Register = React.lazy(() => import("@src/pages/logIn/register"))
const Enroll = React.lazy(() => import("@src/pages/logIn/enroll"))
const ResetPasswords = React.lazy(() => import("@src/pages/logIn/resetPasswords"))
const UserinfoPage = React.lazy(() => import("@src/pages/userinfo"))
const Guidance = React.lazy(() => import("@src/pages/guidance"))
const Introduce = React.lazy(() => import("@src/pages/introduce"))
export default [
    {
        path: "/",
        element: <Guidance/>,
    },
    {
        path: "/introduce",
        element: <Introduce/>,
    },
    {
        path: "/home",
        element: <PrivateRoute><HomePage/></PrivateRoute>,
        errorElement: <ErrorPage/>,
        children: [
            {
                path: "news",
                element: <News/>,
                children: [
                    {
                        index: true,
                        element: <NewsDefault/>,
                    },
                    {
                        path: "privateChat",
                        element: <PrivateChat/>,
                    }, {
                        path: "addFriends",
                        element: <AddFriends/>,
                    },
                    {
                        path: "searchUser",
                        element: <SearchUser/>,
                    },
                ]
            },
            {
                path: "contacts",
                element: <Contacts/>,
            },
            {
                path: "music",
                element: <Music/>,
                children: [
                    {
                        index: true,
                        element: <MusicDefault/>
                    },
                    {
                        path: "songsList",
                        element: <SongsList/>
                    },
                    {
                        path: "searchSuggest",
                        element: <SearchSuggest/>
                    },
                    {
                        path: "search",
                        element: <Search/>
                    },
                    {
                        path: "catList",
                        element: <CatList/>
                    },
                    {
                        path: "songDetail",
                        element: <SongDetail/>
                    }
                ]
            },
            {
                path: "chatRoom",
                element: <ChatRoom/>,
                children: [
                    {
                        index: true,
                        element: <ChatRoomDefault/>
                    }, {
                        path: "chatRoomDetailed",
                        element: <ChatRoomDetailed/>
                    }
                ]
            },
            {
                index: true,
                element: <Navigate replace to="chatRoom"/>,
            }
        ]
    },
    {
        path: "/userinfo",
        element: <PrivateRoute><UserinfoPage/></PrivateRoute>,
    },
    {
        path: "/logIn",
        element: <LogInPage/>,
        children: [
            {
                path: "register",
                element: <Register/>,
            },
            {
                path: "enroll",
                element: <Enroll/>,
            },
            {
                path: "resetPasswords",
                element: <ResetPasswords/>,
            },
            {
                index: true,
                element: <Navigate replace to="register"/>,
            }
        ]
    },
    {
        path: '*',
        element: <ErrorPage/>
    }

]